<?php
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/interfaces/IOrderDetailAccessDao.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/interfaces/IConnectionAccessDao.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/factory/ConnectionFactory.php';
	
	error_reporting (E_ALL ^ E_NOTICE);
	
	$debug = $_SESSION['debug'];

	class MySqlOrderDetailAccessDao implements IOrderDetailAccessDao {
  		/**
		 * Constructor of the Purchase Order detail dao
		 */
	 	public function __construct () {}
		
		/**
		 * Creates a Purchase Order detail
		 */
     	public function createOrderDetail($orderDetail) {
			$pkLine = $orderDetail -> getPkLine();
			$units = $orderDetail -> getUnits();
			$quantity = $orderDetail -> getQuantity();
			$unitCost = $orderDetail -> getUnitCost();
			$pkFkNumberOrderDetail = $orderDetail -> getPkFkNumberOrder();
			$pkFkControlNumberOrderDetail = $orderDetail -> getPkFkControlNumberOrder();
			$pkFkCodeProductInventory = $orderDetail -> getPkFkCodeProductInventory();
			$pkFkRifBranchInventory = $orderDetail -> getPkFkRifBranchInventory();
			
			$connection = ConnectionFactory :: getMySqlConnectionAccessDao();
			$conn = $connection -> openConnection();
				$GLOBALS['debug'] -> log($orderDetail,"LLEGO al DAO -- Purchase Order Detail");
			
			$query = "INSERT INTO REQUEST_DETAIL VALUES ($pkLine, '$units', $quantity, $unitCost, 
				$pkFkNumberOrderDetail, $pkFkControlNumberOrderDetail, $pkFkCodeProductInventory, 
				'$pkFkRifBranchInventory')";
			
			$GLOBALS['debug'] -> log($query, "Query");
			
			$sentence = mysql_query($query, $conn);
			
			$connection -> closeConnection($conn);
			
			if ($sentence)
				return true;
			
			return false;
	 	}
	}
?>